<?php
/**
 * Core_Data_Allmaincategoriesdata
 * get all main categories data
 * @author Adrian Stolarski
 */
class Core_Data_Allmaincategoriesdata implements Core_Data_Mainable, 
        Core_Data_Preparable{
    
    /**
     *
     * @var type $database
     * database handler
     */
    public $database;
    /**
     *
     * @var type $database_query
     * database query handler
     */
    public $database_query;
    
    /**
     * constructor()
     */
    public function __construct() {
        $this->database = new Core_Driver_MysqlImproved;
    }
    
    /**
     * main()
     * get current main category data
     * @param array $variables
     * @return type $current_main_category
     */
    public function main(array $variables = null) {
       $this->database->connect();
       foreach($variables as $key => $value){
           $variables[$key] = $this->database->escape($value);
       }
       $this->prepare_query($variables);
       $this->database->prepare($this->database_query);
       $this->database->query();
       while($categories_data = $this->database->fetch('array')){
           $all_categories_data[$categories_data['main_category_name']] = $categories_data;
       }
       return $all_categories_data;
    }
    
    /**
     * prepare_query();
     * prepare database query
     * 
     * @param array $variables
     */
    public function prepare_query(array $variables = null) {
        $this->database_query = "SELECT * FROM page_main_category;";
    }
    
}
